﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DAL;

/// <summary>
/// Summary description for DeliveryBO
/// </summary>
public class DeliveryBO : DB_SAPDataContext
{
    public DeliveryBO()
    {
        //
        // TODO: Add constructor logic here
        //
    }


    public List<ZD_PRC_OCRG_GETALLResult> GroupCustomerGetAll()
    {
        try
        {
            List<ZD_PRC_OCRG_GETALLResult> result = new List<ZD_PRC_OCRG_GETALLResult>();
            result = ZD_PRC_OCRG_GETALL().ToList();
            return result;
        }
        catch (Exception ex)
        {
            return null;
        }
    }

    public List<ZD_PRC_ZD_TONG_HOP_THEO_ROUTEIDResult> GetDelivery(DateTime dt, string DSRouteId, string DSGroupCode, int userId)
    {
        try
        {
            List<ZD_PRC_ZD_TONG_HOP_THEO_ROUTEIDResult> result = new List<ZD_PRC_ZD_TONG_HOP_THEO_ROUTEIDResult>();
            result = ZD_PRC_ZD_TONG_HOP_THEO_ROUTEID(dt, DSRouteId, DSGroupCode, userId).ToList();
            return result;
        }
        catch (Exception ex)
        {
            return null;
        }
    }
    public ZD_PRC_ZD_TONG_HOP_THEO_ROUTEIDResult GetDeliveryRow1(DateTime dt, string DSRouteId, string DSGroupCode, int userId)
    {
        try
        {
            return ZD_PRC_ZD_TONG_HOP_THEO_ROUTEID(dt, DSRouteId, DSGroupCode, userId).SingleOrDefault();

        }
        catch (Exception ex)
        {
            return null;
        }
    }


    public List<ZD_PRC_ZD_TONG_HOP_CHECK_SL_ISBNResult> CheckISBN()
    {
        try
        {
            List<ZD_PRC_ZD_TONG_HOP_CHECK_SL_ISBNResult> result = new List<ZD_PRC_ZD_TONG_HOP_CHECK_SL_ISBNResult>();
            result = ZD_PRC_ZD_TONG_HOP_CHECK_SL_ISBN().ToList();
            return result;
        }
        catch (Exception ex)
        {
            return null;
        }
    }

    public int Delivery_SO_Temp_Insert(int id, int buoid, DateTime ngaylapphieu, int createUserId)
    {
        try
        {
            return ZD_PRC_ZD_DELIVERY_SO_TEMP_INSERT(id, buoid, ngaylapphieu, createUserId);

        }
        catch
        {
            return -1;
        }
    }

    public int Delivery_SO_Temp_Detail_Insert_Or_Update(int id, int materId, int routeId, string khoId, string makhachhang, int soid, string isbn,string khosachId, DateTime ngayETD, int tsl, int lenhgiaohang, int createUserId, int updateUserId)
    {
        try
        {
            return ZD_PRC_ZD_DELIVERY_SO_TEMP_DETAIL_INSERT_OR_UPDATE(id, materId, routeId, khoId, makhachhang, soid, isbn,khosachId, ngayETD, tsl, lenhgiaohang, createUserId, updateUserId);

        }
        catch
        {
            return -1;
        }
    }
    public int Delivery_SO_Insert(int id, int buoid, DateTime ngaylapphieu, int createUserId)
    {
        try
        {
            return ZD_PRC_ZD_DELIVERY_SO_INSERT(id, buoid, ngaylapphieu, createUserId);

        }
        catch
        {
            return -1;
        }
    }

    public int Delivery_SO_Detail_Insert_Or_Update(int id, int materId, int routeId, string khoId, string makhachhang, int soid, string isbn,string khosachId, DateTime ngayETD, int tsl, int lenhgiaohang, bool datrukho, int slsoanhang, int createUserId, int updateUserId)
    {
        try
        {
            return ZD_PRC_ZD_DELIVERY_SO_DETAIL_INSERT_OR_UPDATE(id, materId, routeId, khoId, makhachhang, soid, isbn,khosachId, ngayETD, tsl, lenhgiaohang, datrukho, slsoanhang, createUserId, updateUserId);


        }
        catch
        {
            return -1;
        }
    }

    public List<ZD_PRC_ZD_DELIVERY_KHO_VIEWResult> Delivery_SO_Detail_Kho_View(DateTime ngay, int buoiId)
    {
        try
        {
            return ZD_PRC_ZD_DELIVERY_KHO_VIEW(ngay, buoiId).ToList();
        }
        catch
        {
            return null;
        }
    }
    public List<ZD_PRC_ZD_DELIVERY_KHO_VIEW_DETAILResult> Delivery_SO_Detail_Kho_View_Detail(int Id)
    {
        try
        {
            return ZD_PRC_ZD_DELIVERY_KHO_VIEW_DETAIL(Id).ToList();
        }
        catch
        {
            return null;
        }
    }
    public List<ZD_PRC_ZD_DELIVERY_SO_TEMP_CS_CHECKResult> Delivery_SO_Temp_CS_View(DateTime ngay, int buoiId, int userId)
    {
        try
        {
            return ZD_PRC_ZD_DELIVERY_SO_TEMP_CS_CHECK(ngay, buoiId, userId).ToList();
        }
        catch
        {
            return null;
        }
    }
    public List<ZD_PRC_ZD_DELIVERY_SO_CS_CHECKResult> Delivery_SO_CS_View(DateTime ngay, int buoiId, int userId)
    {
        try
        {
            return ZD_PRC_ZD_DELIVERY_SO_CS_CHECK(ngay, buoiId, userId).ToList();
        }
        catch
        {
            return null;
        }
    }
    public List<ZD_PRC_ZD_DELIVERY_VIEWResult> Delivery_SO_Detail_View(DateTime ngayeta, int buoiId, string DSrouteId)
    {
        try
        {
            return ZD_PRC_ZD_DELIVERY_VIEW(ngayeta, buoiId, DSrouteId).ToList();
        }
        catch
        {
            return null;
        }
    }
    public int Delivery_SO_Detail_Kho_Save(int id, int updateUserId, bool datrukho, int slsoan)
    {
        try
        {
            return ZD_PRC_ZD_DELIVERY_KHO_SAVE(id, datrukho, slsoan, updateUserId);


        }
        catch
        {
            return -1;
        }
    }
    public List<ZD_PRC_ZD_DELIVERY_SO_TEMP_CS_MAN_GETBYIDResult> Delivery_SO_Temp_Detail_CS_Man_GetByID(string dsId)
    {
        try
        {
            return ZD_PRC_ZD_DELIVERY_SO_TEMP_CS_MAN_GETBYID(dsId).ToList();
        }
        catch
        {
            return null;
        }
    }
    public List<ZD_PRC_ZD_DELIVERY_SO_TEMP_CS_MAN_GETResult> Delivery_SO_Temp_Detail_CS_Man_View(DateTime ngay, int buoiId)
    {
        try
        {
            return ZD_PRC_ZD_DELIVERY_SO_TEMP_CS_MAN_GET(ngay, buoiId).ToList();
        }
        catch
        {
            return null;
        }
    }

    public List<ZD_PRC_ZD_DELIVERY_SO_CS_MAN_GETBYIDResult> Delivery_SO_CS_Man_Get(DateTime ngay, int buoiId)
    {
        try
        {
            return ZD_PRC_ZD_DELIVERY_SO_CS_MAN_GETBYID(ngay, buoiId).ToList();
        }
        catch
        {
            return null;
        }
    }

    public int Delivery_SO_CS_Check_New(DateTime ngay, int buoiId)
    {
        try
        {
            return ZD_PRC_ZD_DELIVERY_CS_CHECK_NEW(ngay, buoiId);
        }
        catch
        {
            return -1;
        }
    }

    public int Delivery_SO_Kho_Check_New(int Id)
    {
        try
        {
            return ZD_PRC_ZD_DELIVERY_KHO_CHECK_NEW(Id);
        }
        catch
        {
            return -1;
        }
    }
    public List<ZD_PRC_ZD_TONG_HOP_THEO_ROUTEResult> GetDeliveryOfRoute(DateTime dt, string DSRouteId, string DSGroupCode)
    {
        try
        {
            List<ZD_PRC_ZD_TONG_HOP_THEO_ROUTEResult> result = new List<ZD_PRC_ZD_TONG_HOP_THEO_ROUTEResult>();
            result = ZD_PRC_ZD_TONG_HOP_THEO_ROUTE(dt, DSRouteId, DSGroupCode).ToList();
            return result;
        }
        catch (Exception ex)
        {
            return null;
        }
    }
    public List<ZD_PRC_ZD_TONG_HOP_THEO_ROUTEID_REPORTResult> GetDeliveryByRouteID(DateTime dt, int RouteId, string DSGroupCode)
    {
        try
        {
            List<ZD_PRC_ZD_TONG_HOP_THEO_ROUTEID_REPORTResult> result = new List<ZD_PRC_ZD_TONG_HOP_THEO_ROUTEID_REPORTResult>();
            result = ZD_PRC_ZD_TONG_HOP_THEO_ROUTEID_REPORT(dt, RouteId, DSGroupCode).ToList();
            return result;
        }
        catch (Exception ex)
        {
            return null;
        }
    }
    public List<ZD_PRC_ZD_DELIVERY_SO_CS_MAN_DETAIL_SEARCHResult> Delivery_SO_CS_Man_Detail_Search(DateTime ngay, int buoiId, int Id)
    {
        try
        {
            return ZD_PRC_ZD_DELIVERY_SO_CS_MAN_DETAIL_SEARCH(ngay, buoiId,Id).ToList();
        }
        catch
        {
            return null;
        }
    }

    public List<ZD_PRC_ZD_DELIVERY_SO_TEMP_CS_DETAIL_SEARCHResult> Delivery_SO_Temp_CS_Detail_Search(DateTime ngay, int buoiId, int Id)
    {
        try
        {
            return ZD_PRC_ZD_DELIVERY_SO_TEMP_CS_DETAIL_SEARCH(ngay, buoiId, Id).ToList();
        }
        catch
        {
            return null;
        }
    }
    public List<ZD_PRC_ZD_DELIVERY_SO_CS_MAN_SEARCHResult> Delivery_SO_CS_Man_Search(DateTime tungay, DateTime denngay)
    {
        try
        {
            return ZD_PRC_ZD_DELIVERY_SO_CS_MAN_SEARCH(tungay, denngay).ToList();
        }
        catch
        {
            return null;
        }
    }

    public List<ZD_PRC_ZD_DELIVERY_SO_TEMP_CS_SEARCHResult> Delivery_SO_Temp_CS_Search(DateTime tungay, DateTime denngay, int CSId)
    {
        try
        {
            return ZD_PRC_ZD_DELIVERY_SO_TEMP_CS_SEARCH(tungay, denngay, CSId).ToList();
        }
        catch
        {
            return null;
        }
    }
}